using AiQiuQuan.Sport.Model.Models;
using AiQiuQuan.Sport.Core;
using AiQiuQuan.Sport.WebApi.Services;
using Microsoft.AspNetCore.Mvc;

namespace AiQiuQuan.Sport.WebApi.Controllers
{
    /// <summary>
    /// 平台广告管理
    /// </summary>
    public class PlatformAdvertisementController : PcApiController
    {
        private readonly IAdvertisementService _advertisementService;

        /// <summary>
        /// 广告管理
        /// </summary>
        public PlatformAdvertisementController(
            IAdvertisementService advertisementService
            )
        {
            _advertisementService = advertisementService;
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="id">约球ID</param>
        [HttpGet("get")]
        public async Task<UnaryResult<AdvertisementDto>> GetAsync(Guid id)
        {
            var result = await _advertisementService.GetAsync(id);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 查询
        /// </summary>
        [HttpPost("query")]
        public async Task<UnaryResult<AdvertisementDto>> QueryAsync(AdvertisementQueryRequestDto request)
        {
            var result = await _advertisementService.QueryAsync(request);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 分页列表
        /// </summary>
        [HttpPost("pagelist")]
        public async Task<UnaryResult<PageResult<AdvertisementDto>>> PageListAsync(AdvertisementPageRequestDto request)
        {
            var result = await _advertisementService.PageListAsync(request);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 新增
        /// </summary>
        [HttpPost("add")]
        public async Task<UnaryResult> AddAsync(AdvertisementAddDto model)
        {
            var result = await _advertisementService.AddAsync(model);
            return result;
        }

        /// <summary>
        /// 修改
        /// </summary>
        [HttpPost("update")]
        public async Task<UnaryResult> UpdateAsync(AdvertisementUpdateDto model)
        {
            var result = await _advertisementService.UpdateAsync(model);
            return result;
        }

        /// <summary>
        /// 删除
        /// </summary>
        [HttpGet("delete")]
        public async Task<UnaryResult> DeleteAsync(Guid id)
        {
            var result = await _advertisementService.DeleteAsync(id);
            return result;
        }
    }
}
